﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;

namespace ZhukBlogLinqExamples.WebParts.SPMenu
{
    [ToolboxItemAttribute(false)]
    public class SPMenu : WebPart
    {
        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/ZhukBlogLinqExamples.WebParts/SPMenu/SPMenuUserControl.ascx";

        HtcMenu menu = new HtcMenu();

        protected override void CreateChildControls()
        {
            Control control = Page.LoadControl(_ascxPath);
            Controls.Add(control);
            menu.Title = "MENU";
            menu.Caption = "CAPTION";
            menu.LargeIconMode = false;
            var item = new HtcMenuOption() {DisplayText = "DT", Description = "Desc"};
            menu.MenuChildren.Add(item);
            Controls.Add(menu);
        }

        public override void RenderControl(HtmlTextWriter writer)
        {
            base.RenderControl(writer);
            menu.RenderAsPopup(writer,true);
        }
    }
}
